import socket
import datetime
 
#HOST = "192.168.1.102"  
PORT = 8888
host = socket.gethostbyname(socket.gethostname())
print(host)
BUFFERSIZE = 1024
ADDR = (host, PORT)
 
TCPClient = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
TCPClient.connect(ADDR)
 
while True:
    senddate = input("input:")
    if senddate:
        TCPClient.send(('%s' % (senddate)).encode("utf-8"))
         
    recvdate = TCPClient.recv(BUFFERSIZE)
    curTime = datetime.datetime.now()
    curTime = curTime.strftime('%Y-%m-%m %H:%M:%S')
    print("%s  %s" % (host, curTime))
    print(recvdate)
    if 'exit' in recvdate or 'EXIT' in recvdate:
        break  
print("client close")
TCPClient.close()
